package com.zzg.common.base.helper;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @ClassName: PagedResult
 * @Description: TODO(分页基类)
 * @author zzg
 * @date 2018年4月28日 上午9:59:57
 * 
 * @param <T>
 */
public class PagedResult<T> {
	private int recordCount = 0;
	private List<T> items = null;
	private Map<String, Object> options = null;

	public int getRecordCount() {
		return recordCount;
	}

	public void setRecordCount(int recordCount) {
		this.recordCount = recordCount;
	}

	public List<T> getItems() {
		return items;
	}

	public void setItems(List<T> items) {
		this.items = items;
	}

	public Map<String, Object> getOptions() {
		return options;
	}

	public void setOptions(Map<String, Object> options) {
		this.options = options;
	}

	@Override
	public String toString() {
		// TODO Auto-generated method stub
		StringBuilder builder = new StringBuilder("Paged Result: ");
		builder.append(" record count:").append(recordCount);
		builder.append(" items:").append(items);
		builder.append(" options:").append(options);
		return builder.toString();
	}

	public static <E> PagedResult<E> create(int count, List<E> items) {
		PagedResult<E> result = new PagedResult<E>();
		result.options = new HashMap<String, Object>();
		result.recordCount = count;
		result.items = items;
		return result;
	}

}
